package com.jiyici.model;

import org.json.JSONException;
import org.json.JSONObject;

import jiyici.Constant.ModelColumn;
import android.content.ContentValues;
import android.database.Cursor;

public class Category extends ClientBaseModel {

    private static final long serialVersionUID = -3401717590629001016L;

    public String name;

    public String displayOrder;
    
    @Override
    public ContentValues toContentValues() {
        ContentValues values = super.toContentValues();
        values.put(ModelColumn.CATEGORY_COLUMN_NAME, name);
        values.put(ModelColumn.CATEGORY_COLUMN_DISPLAY_ORDER, displayOrder);
        return values;
    }

    @Override
    public void fromCursor(Cursor c) {
        super.fromCursor(c);
        name = c.getString(c.getColumnIndex(ModelColumn.CATEGORY_COLUMN_NAME));
        displayOrder = c.getString(c.getColumnIndex(ModelColumn.CATEGORY_COLUMN_DISPLAY_ORDER));
    }
    
    @Override
    public void fromJson(JSONObject json) throws JSONException {
        super.fromJson(json);
        name = json.getString(ModelColumn.CATEGORY_COLUMN_NAME);
        displayOrder = json.getString(ModelColumn.CATEGORY_COLUMN_DISPLAY_ORDER);
    }

    @Override
    public JSONObject toJson() throws JSONException {
        JSONObject json = super.toJson();
        json.put(ModelColumn.CATEGORY_COLUMN_NAME, name);
        json.put(ModelColumn.CATEGORY_COLUMN_DISPLAY_ORDER, displayOrder);
        return json;
    }

    @Override
    public String toString() {
        return "Category [id=" + id + ", userId=" + userId + ", lastmodified=" + lastmodified + ", deleted=" + deleted
                + ", dirty=" + dirty + ", name=" + name + ", displayOrder=" + displayOrder + "]";
    }

}
